﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using System.Windows.Forms;

namespace WindowsFormsApplication3.Datalayer
{
    class Login
    {

        public static bool Authenticate(string uname, string pass)
        {
            OleDbConnection oleDbConnection1 = new System.Data.OleDb.OleDbConnection(Program.ConnStr);
            oleDbConnection1.Open();
            OleDbCommand oleDbCommand1 = new System.Data.OleDb.OleDbCommand("select *  from masterusertable where userid='" + uname + "' AND passsword='" + pass+ "'", oleDbConnection1);
            oleDbCommand1.CommandType = CommandType.Text;
            try
            {
                OleDbDataReader data = oleDbCommand1.ExecuteReader();
                if (data.Read() == true)
                {
                    //   int currentuserpk=data.GetInt16(0);
                    // MessageBox.Show(""+currentuserpk);
                   // this.Hide();
                   // MainMenuForm mainmenuform = new MainMenuForm();
                    //mainmenuform.Show();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("Exception at Database close any Access Database program and restart");
                Console.WriteLine("Error", exp);

            }
            return false;
        }
    }
}
